# Created with PyCharm.
# Project_Name SoftwareTesting2022
# PATH AllExercise
# Files_Name 下拉框的处理.py
# Coding UTF-8
# @Version Python 3.8

# @author GeekChunky
# @Email caiyoupeng00@outlook.com

# @Date 2021/11/23
# @CreatTime 15:41


'''
Documentation comments:
    下拉框的多种方式的实现
'''

# Now Write Down Your Python Code in Editor...
# Wish You Happy Everyday !

import ddt
import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

driver = webdriver.Edge(r'C:\Users\caiyo\AppData\Local\Programs\Python\Python38\BroswerDriver\msedgedriver.exe')
driver.maximize_window()
driver.get('http://192.168.1.251/bsams/front/login.do')
driver.implicitly_wait(10)
driver.find_element_by_xpath('//*[@id="taskId"]').send_keys('660')
driver.find_element_by_xpath('//*[@id="loginName"]').send_keys('xg01')
driver.find_element_by_xpath('//*[@id="password"]').send_keys('xg01')
driver.find_element_by_xpath('//*[@id="vericode"]').send_keys('shtd')
# 点击登录按钮
taskID = (By.XPATH)
driver.find_element_by_xpath('//*[@id="fmedit"]/div[2]/div[6]/input').click()
# 点击菜单栏至供应商
driver.find_element_by_xpath('//*[@id="leftmenu_asset_provider"]').click()
# 核心
Select(driver.find_element_by_xpath('//*[@id="fmsearch"]/div[1]/select')).select_by_index(2)
# 点击搜索按钮
driver.find_element_by_xpath('//*[@id="fmsearch"]/div[3]/input').click()

# 二次定位实现下拉框点击操作
# driver.find_element_by_xpath('//*[@id="fmsearch"]/div[1]/select').click()
# driver.find_element_by_xpath('//*[@id="fmsearch"]/div[1]/select/option[3]')

# 实例化Select
# selector = Select(driver.find_element_by_xpath('//*[@id="fmsearch"]/div[1]/select'))
# 下拉框选择value值为2
# selector.select_by_value('2')
# 下拉框数数，index从0开始
# selector.select_by_index('2')
# 下拉框通过文本信息选择
# selector.select_by_visible_text('已禁用')
